package com.ruoyi.web.controller.resource;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.resource.domain.SysBusinessResourceImageType;
import com.ruoyi.resource.service.ISysBusinessResourceImageTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 图集列表Controller
 *
 * @author ruoyi
 * @date 2023-12-22
 */
@RestController
@RequestMapping("/resource/imageType")
public class SysBusinessResourceImageTypeController extends BaseController
{
    @Autowired
    private ISysBusinessResourceImageTypeService sysBusinessResourceImageTypeService;

    /**
     * 查询图集列表列表
     */
    @PreAuthorize("@ss.hasPermi('resource:imageType:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBusinessResourceImageType sysBusinessResourceImageType)
    {
        startPage();
        List<SysBusinessResourceImageType> list = sysBusinessResourceImageTypeService.selectSysBusinessResourceImageTypeList(sysBusinessResourceImageType);
        return getDataTable(list);
    }

    /**
     * 导出图集列表列表
     */
    @PreAuthorize("@ss.hasPermi('resource:imageType:export')")
    @Log(title = "图集列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBusinessResourceImageType sysBusinessResourceImageType)
    {
        List<SysBusinessResourceImageType> list = sysBusinessResourceImageTypeService.selectSysBusinessResourceImageTypeList(sysBusinessResourceImageType);
        ExcelUtil<SysBusinessResourceImageType> util = new ExcelUtil<SysBusinessResourceImageType>(SysBusinessResourceImageType.class);
        util.exportExcel(response, list, "图集列表数据");
    }

    /**
     * 获取图集列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('resource:imageType:query')")
    @GetMapping(value = "/{imageTypeId}")
    public AjaxResult getInfo(@PathVariable("imageTypeId") Long imageTypeId)
    {
        return success(sysBusinessResourceImageTypeService.selectSysBusinessResourceImageTypeByImageTypeId(imageTypeId));
    }

    /**
     * 新增图集列表
     */
    @PreAuthorize("@ss.hasPermi('resource:imageType:add')")
    @Log(title = "图集列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBusinessResourceImageType sysBusinessResourceImageType)
    {
        return toAjax(sysBusinessResourceImageTypeService.insertSysBusinessResourceImageType(sysBusinessResourceImageType));
    }

    /**
     * 修改图集列表
     */
    @PreAuthorize("@ss.hasPermi('resource:imageType:edit')")
    @Log(title = "图集列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBusinessResourceImageType sysBusinessResourceImageType)
    {
        return toAjax(sysBusinessResourceImageTypeService.updateSysBusinessResourceImageType(sysBusinessResourceImageType));
    }

    /**
     * 删除图集列表
     */
    @PreAuthorize("@ss.hasPermi('resource:imageType:remove')")
    @Log(title = "图集列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{imageTypeIds}")
    public AjaxResult remove(@PathVariable Long[] imageTypeIds)
    {
        return toAjax(sysBusinessResourceImageTypeService.deleteSysBusinessResourceImageTypeByImageTypeIds(imageTypeIds));
    }
}
